home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 August: Technology Seed / ADC Seed CD - August 1999.toast / Carbon SDK 1.0d10c3 / Sample Code / SimpleText / AboutBox.c next >
Encoding:
C/C++ Source or Header  |  1999-05-04  |  4.5 KB  |  161 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        AboutBox.c
  3.  
  4.     Contains:    About Box support for SimpleText
  5.  
  6.     Version:    GX 1.2 or later
  7.  
  8.     Written by:    Tom Dowdy
  9.                 DAL = Dave Lyons
  10.  
  11.     Copyright:    © 1993-1997 by Apple Computer, Inc., all rights reserved.
  12.  
  13.     File Ownership:
  14.  
  15.         DRI:                Tom Dowdy
  16.  
  17.         Other Contact:        Jim Negrette
  18.  
  19.         Technology:            Macintosh Graphics Group
  20.  
  21.     Writers:
  22.  
  23.         (dmp)    Dave Polaschek
  24.         (TD)    Tom Dowdy
  25.  
  26.     Change History (most recent first):
  27.  
  28.          <2>     7/29/97    ted        Removed all of the old and boring "refs"
  29.          <3>      9/9/96    dmp        staticfy local functions to eliminate warnings in MWC.
  30.          <2>     10/2/95    TD        adding support for SC compiler
  31.          <1>     8/21/95    TD        First checked in.
  32.          <2>      9/8/94    DAL        No longer shows the "read only document" balloon help or
  33.                                     keypress alert for the About box (no Radar bug? thought it was
  34.                                     in there). Just added do-nothing routines AboutGetBalloon and
  35.                                     AboutKeyEvent.
  36.  
  37. */
  38.  
  39. #include "MacIncludes.h"
  40.  
  41. #include "AboutBox.h"
  42.  
  43.  
  44. // --------------------------------------------------------------------------------------------------------------
  45. // INTERNAL ROUTINES
  46. // --------------------------------------------------------------------------------------------------------------
  47. static void DrawCenteredStringAt(Str255 theString, short yLocation)
  48. {
  49.     Rect    portRect;
  50.     CGrafPtr thePort = GetQDGlobalsThePort();
  51.  
  52.     GetPortBounds(thePort, &portRect);
  53.     
  54.     MoveTo(portRect.left + ((portRect.right-portRect.left) >> 1) -
  55.                             (StringWidth(theString) >> 1), yLocation);
  56.     DrawString(theString);
  57.     
  58. } // DrawCenteredStringAt
  59.  
  60. // --------------------------------------------------------------------------------------------------------------
  61. // OOP INTERFACE ROUTINES
  62. // --------------------------------------------------------------------------------------------------------------
  63.  
  64. static OSErr    AboutUpdateWindow(WindowPtr pWindow, WindowDataPtr pData)
  65. {
  66. #pragma unused (pData)
  67.  
  68.     Str255        theString;
  69.         Rect        bounds;
  70.  
  71.     // type style for application name
  72.     TextFont(systemFont);
  73.     TextSize(12);
  74.     
  75.     // name of application
  76.     GetIndString(theString, kAboutStrings, 1);
  77.     DrawCenteredStringAt(theString, 32);
  78.     
  79.     // type style for all others
  80.     TextFont(applFont);
  81.     TextSize(9);
  82.     
  83.     // author names
  84.     GetIndString(theString, kAboutStrings, 2);
  85.     DrawCenteredStringAt(theString, 50);
  86.     GetIndString(theString, kAboutStrings, 3);
  87.     DrawCenteredStringAt(theString, 65);
  88.     GetIndString(theString, kAboutStrings, 4);
  89.     DrawCenteredStringAt(theString, 80);
  90.     
  91.     // copyright, on the left
  92.     GetIndString(theString, kAboutStrings, 5);
  93.     MoveTo(10, 105);
  94.     DrawString(theString);
  95.     
  96.     // version, on the right
  97.     GetIndString(theString, kAboutStrings, 6);
  98.         MoveTo((GetWindowPortBounds(pWindow, &bounds)->right - 10) - StringWidth(theString), 105);
  99.     DrawString(theString);
  100.     
  101.     return noErr;
  102.     
  103. } // AboutUpdateWindow
  104.  
  105. // --------------------------------------------------------------------------------------------------------------
  106.  
  107. static OSErr    AboutGetBalloon(WindowPtr pWindow, WindowDataPtr pData, 
  108.         Point *localMouse, short * returnedBalloonIndex, Rect *returnedRectangle)
  109. {
  110. #pragma unused (pWindow, pData, localMouse, returnedRectangle)
  111.  
  112.     *returnedBalloonIndex = iNoBalloon;
  113.     
  114.     return noErr;
  115.     
  116. } // AboutGetBalloon
  117.  
  118. // --------------------------------------------------------------------------------------------------------------
  119.  
  120. static OSErr    AboutKeyEvent(WindowPtr pWindow, WindowDataPtr pData, EventRecord *pEvent, Boolean isMotionKey)
  121. {
  122.     #pragma unused(pWindow, pData, pEvent, isMotionKey)
  123.  
  124.     return noErr;
  125.  
  126. } // AboutKeyEvent
  127.  
  128. // --------------------------------------------------------------------------------------------------------------
  129.  
  130. static OSErr    AboutMakeWindow(WindowPtr pWindow, WindowDataPtr pData)
  131. {
  132. #pragma unused (pWindow)
  133.  
  134.     pData->pUpdateWindow = (UpdateWindowProc) AboutUpdateWindow;
  135.     pData->pGetBalloon     = (GetBalloonProc) AboutGetBalloon;
  136.     pData->pKeyEvent     = (KeyEventProc) AboutKeyEvent;
  137.  
  138.     return noErr;
  139.     
  140. } // AboutMakeWindow
  141.  
  142. // --------------------------------------------------------------------------------------------------------------
  143.  
  144. OSErr    AboutPreflightWindow(PreflightPtr pPreflightData)
  145. {
  146.     pPreflightData->resourceID         = kAboutWindowID;
  147.     pPreflightData->continueWithOpen     = true;
  148.     pPreflightData->makeProcPtr         = (MakeWindowProc) AboutMakeWindow;
  149.     
  150.     return noErr;
  151.     
  152. } // AboutPreflightWindow
  153.  
  154. // --------------------------------------------------------------------------------------------------------------
  155.  
  156. void AboutGetFileTypes(OSType * pFileTypes, OSType * pDocumentTypes, short * numTypes)
  157. {
  158. #pragma unused (pFileTypes, pDocumentTypes, numTypes)
  159.  
  160. } // AboutGetFileTypes
  161.